import QtQuick 1.1
import com.nokia.meego 1.0

import "DucankoStyle.js" as DucankoStyle

Page {

    //background image
    Image {
        id: background
        anchors.fill: parent
        source: "qrc:/images/pozadina1.png"
        fillMode: "Stretch"
    }

    //sectionTop
    Item {
        id: sectionTop

        anchors {
            horizontalCenter: parent.horizontalCenter

            top: parent.top
            left: parent.left
        }

        height: label.height*3
        width: parent.width

        Image{
            id: bgTop
            anchors.fill: parent
            source: "qrc:/images/diopozadine-01gore.png"
            fillMode: "Stretch"
        }

        Label {
            id: label
            anchors.centerIn: parent
            text: qsTr("Settings!")
            font.family: DucankoStyle.FONT_FAMILY
            font.pixelSize: DucankoStyle.FONT_PAGE_TITLE_SIZE
        }
    }

    Item{
        id: sectionCenter
        anchors {
            horizontalCenter: parent.horizontalCenter
            verticalCenter: parent.verticalCenter
        }

        height: textCurrentLanguage.height+chooseLanguage.height+textCurrentLanguage2.height
        width: parent.width

        Text{
            id: textCurrentLanguage

            anchors.top: parent.top
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.margins: 10

            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter

            font.family: DucankoStyle.FONT_FAMILY
            font.pixelSize: DucankoStyle.FONT_MESSAGE_SIZE
            text: qsTr("Current language:")
        }
        Text{
            id: textCurrentLanguage2

            anchors.top: textCurrentLanguage.bottom
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.margins: 10

            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter

            font.family: DucankoStyle.FONT_FAMILY
            font.pixelSize: DucankoStyle.FONT_BIG_TITLE_SIZE

            text: modelLanguages.get(qmlHandler.getChosenLanguageIndex()).name
        }
        Button {
            id: chooseLanguage

            anchors.top: textCurrentLanguage2.bottom
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.margins: 10

            text: qsTr("Change language");

            onClicked: {
                dialogLanguages.open();
            }
        }

    }



    //sectionBottom
    Item {
        id: sectionBottom

        anchors {
            horizontalCenter: parent.horizontalCenter
            left: parent.left
            bottom: parent.bottom
        }

        width: parent.width
        height: buttonBack.height+2*10

        Image{
            id: bgBottom
            anchors.fill: parent
            source: "qrc:/images/diopozadine-02dolje.png"
            fillMode: "Stretch"
        }

        Button{
            id: buttonBack
            text: qsTr("Back")

            width: parent.width

            anchors {
                horizontalCenter: parent.horizontalCenter
                left: parent.left
                bottom: parent.bottom
                margins: 10
            }

            onClicked: appWindow.pageStack.pop();

        }
    }


    MySelectionDialog {
        id: dialogLanguages

        titleText: qsTr("Select language")
        model: modelLanguages
        selectedIndex: qmlHandler.getChosenLanguageIndex()

        onAccepted: {
            qmlHandler.settings_SetLanguage(modelLanguages.get(dialogLanguages.selectedIndex).idJezika)
            dialogLanguages.titleText=modelLanguages.get(dialogLanguages.selectedIndex).name
            textCurrentLanguage2.text=modelLanguages.get(dialogLanguages.selectedIndex).name
            translate()
            settingsTranslate()
        }
    }

    function settingsTranslate(){
        label.text=qsTr("Settings!")
        textCurrentLanguage.text=qsTr("Current language:")
        buttonBack.text=qsTr("Back")
        chooseLanguage.text=qsTr("Change language")

    }
}
